﻿using Deixei.Domain;
using Deixei.Web.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Deixei.WebApi.Controllers
{
    public class CustomersController : DeixeiApiController
    {
        // GET api/<controller>
        public IEnumerable<Customer> Get()
        {
            return base.ApplicationContext.ServiceLayerContext.CustomerService.GetAllCustomers(); 
        }

        // GET api/<controller>/5
        public Customer Get(int id)
        {
            return base.ApplicationContext.ServiceLayerContext.CustomerService.GetCustomer(id); 
        }

        // POST api/<controller>
        //public Customer Post([FromBody]Customer value)
        public Customer Post()
        {
            Customer x = new Customer()
            {
                Code = "111",
                Description = "222",
                Name = "333"
            };

            return base.ApplicationContext.ServiceLayerContext.CustomerService.AddCustomer(x); 
        }

        // PUT api/<controller>/5
        public Customer Put(int id, [FromBody]Customer value)
        {
            return base.ApplicationContext.ServiceLayerContext.CustomerService.UpdateCustomer(id, value); 
        }

        // DELETE api/<controller>/5
        public Customer Delete(int id)
        {
            return base.ApplicationContext.ServiceLayerContext.CustomerService.DeleteCustomer(id); 
        }
    }
    
}